﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using QLKetNoi;
using System.Data.Linq;

namespace QLPhanQuyen.DAO
{
    public class NhomChucNangDAO
    {
        QLDNDataContext db = new QLDNDataContext();
        Table<NHOMCHUCNANG> nhoms;

        public List<string> DSTenNhomChucNang()
        {
            nhoms = db.GetTable<NHOMCHUCNANG>();
            var query = (from nhom in nhoms
                         select nhom.TenNhomChucNang).ToList();
            return query;
        }

        public string LayMaTheoTen(string tenNhomChucNang)
        {
            nhoms = db.GetTable<NHOMCHUCNANG>();

            var query = (from nhom in nhoms
                         where nhom.TenNhomChucNang == tenNhomChucNang
                         select nhom.MaNhomChucNang).FirstOrDefault();
            return query;
        }
    }
}
